package com.jing.qq.qq;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class SelectActivity extends AppCompatActivity {
    private Button[] btns= new Button[3];
    private Class[] targetActivities = new Class[]{MessageListActivity.class,ContactActivity.class,PluginActivity.class};
    private int[] bottomImgs = new int[]{R.drawable.skin_tab_icon_conversation_normal,R.drawable.skin_tab_icon_contact_normal,R.drawable.skin_tab_icon_plugin_normal};
    private int[] bottomImgsSelect = new int[]{R.drawable.skin_tab_icon_conversation_selected,R.drawable.skin_tab_icon_contact_selected,R.drawable.skin_tab_icon_plugin_selected};
    private int i;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }
    protected void init(int index){
        btns[0]= (Button) findViewById(R.id.conversation_btn);
        btns[1]= (Button) findViewById(R.id.contact_btn);
        btns[2]= (Button) findViewById(R.id.plugin_btn);

        for(i=0;i<btns.length;i++){
            final int temp=i;
            if(index==i){
                btns[i].setBackgroundResource(bottomImgsSelect[i]);
            }else{
                btns[i].setBackgroundResource(bottomImgs[i]);
                btns[i].setOnClickListener(new View.OnClickListener(){

                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(SelectActivity.this,targetActivities[temp]);
                        startActivity(intent);
                        finish();
                    }
                });
            }
        }
    }
}
